/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.phoenix.repository.query.jql;

import java.util.Hashtable;

import net.phoenix.repository.query.jql.antlr.JQLTokenTypes;
import antlr.ASTFactory;
import antlr.collections.AST;

/**
 * Jigsaw server
 * 
 * @author    <a href="shamphone@gmail.com">Li XiongFeng</a>
 * @date      2012-4-21
 * @version   1.0.0
 */
public class JQLASTFactory extends ASTFactory implements JQLTokenTypes{
	
	public JQLASTFactory(){
		Hashtable<Integer, Class<? extends AST>> mapping = new Hashtable<Integer, Class<? extends AST>>();
		mapping.put(JQLTokenTypes.QUERY, QueryAST.class);
		mapping.put(JQLTokenTypes.SELECT_FROM, SelectFromAST.class);
		mapping.put(JQLTokenTypes.WHERE, WhereAST.class);
		mapping.put(JQLTokenTypes.ORDER, OrderByAST.class);
		mapping.put(JQLTokenTypes.FROM, FromClauseAST.class);
		mapping.put(JQLTokenTypes.SELECT, SelectClauseAST.class);
		mapping.put(JQLTokenTypes.RANGE, SelectorAST.class);
		mapping.put(JQLTokenTypes.IDENT, IdentifierAST.class);
		mapping.put(JQLTokenTypes.AS, AsAST.class);
		mapping.put(JQLTokenTypes.AND, AndAST.class);
		mapping.put(JQLTokenTypes.OR, OrAST.class);
		mapping.put(JQLTokenTypes.NOT, NotAST.class);
		mapping.put(JQLTokenTypes.LE, ComparisonAST.class);
		mapping.put(JQLTokenTypes.GE, ComparisonAST.class);
		mapping.put(JQLTokenTypes.LT, ComparisonAST.class);
		mapping.put(JQLTokenTypes.GT, ComparisonAST.class);
		mapping.put(JQLTokenTypes.EQ, ComparisonAST.class);
		mapping.put(JQLTokenTypes.NE, ComparisonAST.class);
		mapping.put(JQLTokenTypes.IS, ComparisonAST.class);
		mapping.put(JQLTokenTypes.IS_NULL, ComparisonAST.class);
		mapping.put(JQLTokenTypes.IS_NOT_NULL, ComparisonAST.class);
		mapping.put(JQLTokenTypes.SQL_NE, ComparisonAST.class);
		mapping.put(JQLTokenTypes.JOIN, JoinAST.class);
		mapping.put(JQLTokenTypes.DOT, DotExpressionAST.class);
		mapping.put(JQLTokenTypes.NUM_BIG_DECIMAL, NumberAST.class);
		mapping.put(JQLTokenTypes.NUM_BIG_INTEGER, NumberAST.class);		
		mapping.put(JQLTokenTypes.NUM_DOUBLE, NumberAST.class);		
		mapping.put(JQLTokenTypes.NUM_FLOAT, NumberAST.class);		
		mapping.put(JQLTokenTypes.NUM_INT, NumberAST.class);		
		mapping.put(JQLTokenTypes.NUM_LONG, NumberAST.class);
		mapping.put(JQLTokenTypes.WITH,JoinConditionAST.class);
		mapping.put(JQLTokenTypes.ASCENDING,LiteralAST.class);
		mapping.put(JQLTokenTypes.DESCENDING,LiteralAST.class);
		mapping.put(JQLTokenTypes.NULL,NullAST.class);
		mapping.put(JQLTokenTypes.QUOTED_STRING,StringAST.class);
		mapping.put(JQLTokenTypes.DOLLAR,ParameterAST.class);
		mapping.put(JQLTokenTypes.COLON,QNameAST.class);
		super.setTokenTypeToASTClassMap(mapping);
		this.theASTNodeTypeClass =  JQLBaseAST.class;
	}


}
